from itertools import accumulate
from typing import *


class Solution:
    def pivotIndex(self, nums: List[int]) -> int:
        sums = sum(nums)
        tot = 0
        for i, v in enumerate(nums):
            if sums - tot - v == tot:
                return i
            tot += v
        return -1
